import c4d

# arnold
AR_NODESPACE = "com.autodesk.arnold.nodespace" 
AR_SHADER_PREFIX = "com.autodesk.arnold.shader."

# material id
ARNOLD_SHADER_NETWORK = 1033991

# root port ids
ARNOLD_SHADER_PORT_ID = 537905099
ARNOLD_DISPLACEMENT_PORT_ID = 537905100
ARNOLD_VIEWPORT_PORT_ID = 537906863
ARNOLD_HISTOGRAM_PORT_ID = 537908968
ARNOLD_VCOLOR_DATATYPE_LEGACYID = 1035785
ARNOLD_VCOLOR_DATATYPE = "com.autodesk.arnold.datatype.vcolor"

C4DAI_SHADERLINK_CONTAINER = 9988000
C4DAI_SHADERLINK_TYPE = 101
C4DAI_SHADERLINK_VALUE = 102
C4DAI_SHADERLINK_TEXTURE = 103
C4DAI_SHADERLINK_MATERIAL = 104

C4DAI_GVC4DSHADER_BITMAP_COLOR_SPACE = 10101

C4DTOA_MSG_GET_NODEMATERIAL_CUSTOMDATA = 1093
C4DTOA_MSG_SET_NODEMATERIAL_CUSTOMDATA = 1094

ARNOLD_SCENE_HOOK = 1032309
# output component ids
ARNOLD_PARAMCOMP_R = 1
ARNOLD_PARAMCOMP_G = 2
ARNOLD_PARAMCOMP_B = 3
ARNOLD_PARAMCOMP_A = 4
ARNOLD_PARAMCOMP_X = 5
ARNOLD_PARAMCOMP_Y = 6
ARNOLD_PARAMCOMP_Z = 7

# message ids
C4DTOA_MSG_TYPE = 1000
C4DTOA_MSG_PARAM1 = 2001
C4DTOA_MSG_PARAM2 = 2002
C4DTOA_MSG_PARAM3 = 2003
C4DTOA_MSG_PARAM4 = 2004
C4DTOA_MSG_PARAM5 = 2005
C4DTOA_MSG_RESP1 = 2011
C4DTOA_MSG_RESP2 = 2012
C4DTOA_MSG_RESP3 = 2013
C4DTOA_MSG_RESP4 = 2014
C4DTOA_MSG_QUERY_SHADER_NETWORK = 1028
C4DTOA_MSG_ADD_SHADER = 1029
C4DTOA_MSG_REMOVE_SHADER = 1030
C4DTOA_MSG_ADD_CONNECTION = 1031
C4DTOA_MSG_REMOVE_CONNECTION = 1032
C4DTOA_MSG_CONNECT_ROOT_SHADER = 1033
C4DTOA_MSG_DISCONNECT_ROOT_SHADER = 1034
C4DTOA_MSG_ALIGN_NODES = 1097

# shader type ids
ARNOLD_SHADER_GV = 1033990
ARNOLD_C4D_SHADER_GV = 1034190
ARNOLD_REFERENCE_GV = 1035541
  
C4DAI_GVSHADER_TYPE = 200
C4DAI_GVC4DSHADER_TYPE = 200

# C4D shader ids
C4DAIN_C4D_BITMAP = 904247772
C4DAIN_C4D_NOISE = 218464707
C4DAIN_C4D_SUBSTANCE_SHADER = 799632067
C4DAIN_C4D_VERTEX_MAP = 1896336102
C4DShaderIdMap = {
    c4d.Xbitmap: C4DAIN_C4D_BITMAP,
    c4d.Xnoise: C4DAIN_C4D_NOISE,
    c4d.Xsubstance: C4DAIN_C4D_SUBSTANCE_SHADER,
    c4d.Xvertexmap: C4DAIN_C4D_VERTEX_MAP,
}

# Arnold shader ids
C4DAIN_BLACKBODY = 1326266352
C4DAIN_DISPLACEMENT = 1227821282
C4DAIN_LIGHT_BLOCKER = 974577342
C4DAIN_OBJECT = 301260540
C4DAIN_OSL = 193501779
C4DAIN_RAMP_FLOAT = 1343782602
C4DAIN_RAMP_RGB = 499635473
C4DAIN_RANDOM = 417623846
C4DAIN_REFERENCE = 1491778796
C4DAIN_SHADOW_MATTE = 1432373531
C4DAIN_SPACE_TRANSFORM = 778771884
C4DAIN_TRIGO = 275933738
C4DAIN_VALUE = 277698370
C4DAIN_XPARTICLES = 206657884

LIGHT_BLOCKER_SHADER_ID = 1035773
OSL_SHADER_ID = 1050718
BLACKBODY_SHADER_ID = 1034217
RAMP_FLOAT_SHADER_ID = 1034228
RAMP_RGB_SHADER_ID = 1034229
RANDOM_SHADER_ID = 1034221
SHADOW_MATTE_SHADER_ID = 1034222
SPACE_TRANSFORM_SHADER_ID = 1034223
TRIGO_SHADER_ID = 1034226
VALUE_SHADER_ID = 1054367
OBJECT_SHADER_ID = 1055077
XPARTICLES_SHADER_ID = 1051148
DISPLACEMENT_SHADER_ID = 1051169
ArnoldCustomShaderIdMap = {
    LIGHT_BLOCKER_SHADER_ID: C4DAIN_LIGHT_BLOCKER,
    OSL_SHADER_ID: C4DAIN_OSL,
    BLACKBODY_SHADER_ID: C4DAIN_BLACKBODY,
    RAMP_FLOAT_SHADER_ID: C4DAIN_RAMP_FLOAT,
    RAMP_RGB_SHADER_ID: C4DAIN_RAMP_RGB,
    RANDOM_SHADER_ID: C4DAIN_RANDOM,
    SHADOW_MATTE_SHADER_ID: C4DAIN_SHADOW_MATTE,
    SPACE_TRANSFORM_SHADER_ID: C4DAIN_SPACE_TRANSFORM,
    TRIGO_SHADER_ID: C4DAIN_TRIGO,
    VALUE_SHADER_ID: C4DAIN_VALUE,
    OBJECT_SHADER_ID: C4DAIN_OBJECT,
    XPARTICLES_SHADER_ID: C4DAIN_XPARTICLES,
    DISPLACEMENT_SHADER_ID: C4DAIN_DISPLACEMENT,    
}

#tip Arnold ID
# C4DtoA/api/include/c4dtoa_symbols.h
ARNOLD_DRIVER = 1030141
ARNOLD_AOV = 1030369

# C4DtoA/api/include/util/Constants.h
C4DTOA_MSG_TYPE = 1000
C4DTOA_MSG_INIT_DEFAULTS = 1011

# C4DtoA/api/include/util/NodeIds.h
C4DAIN_DRIVER_PNG = 9492523
C4DAIN_DRIVER_EXR = 9504161
C4DAIN_DRIVER_TIFF = 313114887
C4DAIN_DRIVER_C4D_DISPLAY = 1927516736

DRIVER_NAME_MAP: dict = {1927516736: "Display driver", 
                         1058716317: "Deep exr",
                         9504161: "exr",
                         313466666: "jpg",
                         9492523: "png",
                         313114887: "tiff"
                         }

# C4DtoA/res/description/arnold_driver.h
C4DAI_DRIVER_TYPE = 101

# C4DtoA/res/description/ainode_driver_***.h
C4DAIP_DRIVER_EXR_FILENAME = 1285755954
C4DAIP_DRIVER_DEEPEXR_FILENAME = 1429220916
C4DAIP_DRIVER_JPEG_FILENAME = 766183461
C4DAIP_DRIVER_PNG_FILENAME = 1807654404
C4DAIP_DRIVER_TIFF_FILENAME = 1913388456
C4DAIP_DRIVER_ALL_FILENAME = [
    C4DAIP_DRIVER_EXR_FILENAME, 
    C4DAIP_DRIVER_DEEPEXR_FILENAME, 
    C4DAIP_DRIVER_JPEG_FILENAME,
    C4DAIP_DRIVER_PNG_FILENAME,
    C4DAIP_DRIVER_TIFF_FILENAME]

# C4DtoA\res\description\ainode_driver_exr.h
C4DAI_DRIVER_EXR_MAIN_GRP          = 1000

ARNOLD_DUMMY_BITMAP_SAVER   = 1035823

C4DAIP_DRIVER_EXR_COMPRESSION = 676823551
C4DAIP_DRIVER_EXR_HALF_PRECISION = 317968755
C4DAIP_DRIVER_EXR_TILED = 1109730913
C4DAIP_DRIVER_EXR_MULTIPART = 2078120241
C4DAIP_DRIVER_EXR_COLOR_SPACE = 1181188201
C4DAIP_DRIVER_EXR_PRESERVE_LAYER_NAME = 2038455371
C4DAIP_DRIVER_EXR_AUTOCROP = 987293958
C4DAIP_DRIVER_EXR_APPEND = 1298458693
C4DAIP_DRIVER_EXR_CUSTOM_ATTRIBUTES = 1368176590
C4DAIP_DRIVER_EXR_NAME = 554454610

C4DAIP_DRIVER_JPEG_COLOR_SPACE = 927936370
C4DAIP_DRIVER_PNG_COLOR_SPACE = 68324877
C4DAIP_DRIVER_TIFF_COLOR_SPACE = 1213105359

C4DAIP_DRIVER_COLOR_SPACE = [C4DAIP_DRIVER_EXR_COLOR_SPACE,
                             C4DAIP_DRIVER_JPEG_COLOR_SPACE,
                             C4DAIP_DRIVER_PNG_COLOR_SPACE,
                             C4DAIP_DRIVER_TIFF_COLOR_SPACE
                             ]

# C4DtoA/res/c4d_symbols.h
ARNOLD_SCENE_EXPORT = 1029993
SCENE_EXPORT_FORMAT_ASS = 193450604
SCENE_EXPORT_FORMAT_USD = 193472369
SCENE_EXPORT_OBJECT_MODE_ALL = 0
SCENE_EXPORT_OBJECT_MODE_SELECTED = 1
SCENE_EXPORT_OBJECT_MODE_SELECTED_INDIVIDUALLY = 2

# C4DtoA/res/description/ainode_skydome_light.h
C4DAIP_SKYDOME_LIGHT_COLOR = 268620635
# C4DtoA/res/description/ainode_quad_light.h
C4DAIP_QUAD_LIGHT_COLOR = 2010942260

C4DAIP_DOME_LIGHT_COLOR = 1458609997

C4DAIP_DRIVER_PNG_FORMAT = 775847732
ARNOLD_OBJECTMASK_TAG       = 1034693
ARNOLD_TAG                  = 1029989
ARNOLD_LIGHT                = 1030424
C4DAIN_CYLINDER_LIGHT = 1944046294
C4DAIN_DISK_LIGHT = 998592185
C4DAIN_DISTANT_LIGHT = 1381557517
C4DAIN_MESH_LIGHT = 804868393
C4DAIN_PHOTOMETRIC_LIGHT = 1980850506
C4DAIN_POINT_LIGHT = 381492518
C4DAIN_QUAD_LIGHT = 1218397465
C4DAIN_SKYDOME_LIGHT = 2054857832
C4DAIN_SPOT_LIGHT = 876943490
#NOTE this is a fake node, does not exist in Arnold core
C4DAIN_LIGHT_PORTAL = 1362015054   

# C4DtoA\res\description\ainode_quad_light.h
C4DAI_QUAD_LIGHT_WIDTH = 2034436501
C4DAI_QUAD_LIGHT_HEIGHT = 2120286158
C4DAI_QUAD_LIGHT_AOV = 9011
C4DAI_QUAD_LIGHT_LOOKAT = 100107

C4DAIP_QUAD_LIGHT_VERTICES = 1675375270
C4DAIP_QUAD_LIGHT_RESOLUTION = 1748091575
C4DAIP_QUAD_LIGHT_ROUNDNESS = 1641633270
C4DAIP_QUAD_LIGHT_SOFT_EDGE = 1632353189
C4DAIP_QUAD_LIGHT_SPREAD = 1730825676
C4DAIP_QUAD_LIGHT_PORTAL = 1849401433
C4DAIP_QUAD_LIGHT_MATRIX = 1983340534
C4DAIP_QUAD_LIGHT_COLOR = 2010942260
C4DAIP_QUAD_LIGHT_INTENSITY = 67722820
C4DAIP_QUAD_LIGHT_EXPOSURE = 1655166224
C4DAIP_QUAD_LIGHT_CAST_SHADOWS = 1630188088
C4DAIP_QUAD_LIGHT_CAST_VOLUMETRIC_SHADOWS = 1554489247
C4DAIP_QUAD_LIGHT_SHADOW_DENSITY = 483322842
C4DAIP_QUAD_LIGHT_SHADOW_COLOR = 1754675065
C4DAIP_QUAD_LIGHT_SAMPLES = 1875225526
C4DAIP_QUAD_LIGHT_NORMALIZE = 1502846298
C4DAIP_QUAD_LIGHT_CAMERA = 1920007390
C4DAIP_QUAD_LIGHT_TRANSMISSION = 599607935
C4DAIP_QUAD_LIGHT_DIFFUSE = 532023995
C4DAIP_QUAD_LIGHT_SPECULAR = 111080596
C4DAIP_QUAD_LIGHT_SSS = 1650653106
C4DAIP_QUAD_LIGHT_INDIRECT = 808309255
C4DAIP_QUAD_LIGHT_MAX_BOUNCES = 1497124329
C4DAIP_QUAD_LIGHT_VOLUME_DENSITY = 1225731220
C4DAIP_QUAD_LIGHT_FILTERS = 1172406162
C4DAIP_QUAD_LIGHT_MOTION_START = 939922632
C4DAIP_QUAD_LIGHT_MOTION_END = 894399297
C4DAIP_QUAD_LIGHT_VOLUME_SAMPLES = 808586593
C4DAIP_QUAD_LIGHT_VOLUME = 1614803219
C4DAIP_QUAD_LIGHT_AOV = 1650672837
C4DAIP_QUAD_LIGHT_NAME = 1362822966

# plugin ids

ARNOLD_RENDERER             = 1029988
ARNOLD_TAG                  = 1029989
ARNOLD_PARAM_DATATYPE       = 1029991
ARNOLD_PARAM_RESOURCETYPE   = 1029992
ARNOLD_DRIVER               = 1030141
ARNOLD_AOV                  = 1030369
ARNOLD_TP                   = 1030371
ARNOLD_CAMERA               = 1030423
ARNOLD_LIGHT                = 1030424
ARNOLD_SHAPE                = 1030425
ARNOLD_SCENE_HOOK           = 1032309
ARNOLD_MESH_LIGHT_TAG       = 1032418
ARNOLD_PROCEDURAL           = 1032509
ARNOLD_VOLUME               = 1033693
ARNOLD_SHADER_GV            = 1033990
ARNOLD_C4D_SHADER_GV        = 1034190
ARNOLD_SHADER_NETWORK       = 1033991
ARNOLD_GV_HOOK              = 1034003
ARNOLD_GV_CLASS             = 1034173
ARNOLD_GV_AISHADER_GROUP    = 1034174
ARNOLD_TFD_TAG              = 1034388
ARNOLD_XPARTICLES_TAG       = 1034537
ARNOLD_SKY                  = 1034624
ARNOLD_OBJECTMASK_TAG       = 1034693
ARNOLD_SUBDIVISION_TAG      = 1035157
ARNOLD_REFERENCE_GV         = 1035541
ARNOLD_LIGHT_BLOCKER_GEO    = 1035772
ARNOLD_DUMMY_BITMAP_SAVER   = 1035823
ARNOLD_TX_LOADER            = 1035950
ARNOLD_PREFERENCES          = 1036062
ARNOLD_MESH_PARTICLES_TAG   = 1036721
ARNOLD_CUSTOM_AOV_TAG       = 1036856
ARNOLD_VIEWPORT_SHADER      = 1037542
ARNOLD_MESSAGE              = 1037879
ARNOLD_BACKGROUND_TAG       = 1038209
ARNOLD_MESH_VOLUME_TAG      = 1039470
ARNOLD_OPERATOR             = 1040497
ARNOLD_OPERATOR_GV          = 1040805
ARNOLD_VOLUME_OBJECT_TAG    = 1041675
ARNOLD_VOLUME_LOADER_TAG    = 1041676
ARNOLD_SCATTER              = 1055097
ARNOLD_IMAGER_VP            = 1055310
ARNOLD_IMAGER               = 1055723
ARNOLD_XPEXPLOSIAFX_TAG     = 1056644

# dome
C4DAI_SKYDOME_LIGHT_AOV = 9011   
C4DAI_SKYDOME_LIGHT_FLIP = 1814071761

C4DAI_SKYDOME_COMPATIBILITY = 199999

C4DAIP_SKYDOME_LIGHT_RESOLUTION = 1173197478
C4DAIP_SKYDOME_LIGHT_FORMAT = 156927185
C4DAIP_SKYDOME_LIGHT_PORTAL_MODE = 576441124
C4DAIP_SKYDOME_LIGHT_MATRIX = 100495259
C4DAIP_SKYDOME_LIGHT_COLOR = 268620635
C4DAIP_SKYDOME_LIGHT_INTENSITY = 310602835
C4DAIP_SKYDOME_LIGHT_EXPOSURE = 100719935
C4DAIP_SKYDOME_LIGHT_CAST_SHADOWS = 624634505
C4DAIP_SKYDOME_LIGHT_CAST_VOLUMETRIC_SHADOWS = 1311663122
C4DAIP_SKYDOME_LIGHT_SHADOW_DENSITY = 652131435
C4DAIP_SKYDOME_LIGHT_SHADOW_COLOR = 749121482
C4DAIP_SKYDOME_LIGHT_SAMPLES = 1828121093
C4DAIP_SKYDOME_LIGHT_NORMALIZE = 1745726313
C4DAIP_SKYDOME_LIGHT_DIFFUSE = 579128428
C4DAIP_SKYDOME_LIGHT_SPECULAR = 1665526885
C4DAIP_SKYDOME_LIGHT_SSS = 966039935
C4DAIP_SKYDOME_LIGHT_INDIRECT = 1932211752
C4DAIP_SKYDOME_LIGHT_MAX_BOUNCES = 1006206950
C4DAIP_SKYDOME_LIGHT_VOLUME_DENSITY = 1056922627
C4DAIP_SKYDOME_LIGHT_FILTERS = 1125301729
C4DAIP_SKYDOME_LIGHT_MOTION_START = 1945476215
C4DAIP_SKYDOME_LIGHT_MOTION_END = 1469293394
C4DAIP_SKYDOME_LIGHT_VOLUME_SAMPLES = 977395186
C4DAIP_SKYDOME_LIGHT_VOLUME = 469032574
C4DAIP_SKYDOME_LIGHT_AOV = 966020204
C4DAIP_SKYDOME_LIGHT_SHADER = 342910877
C4DAIP_SKYDOME_LIGHT_CAMERA = 291124113
C4DAIP_SKYDOME_LIGHT_TRANSMISSION = 405945648
C4DAIP_SKYDOME_LIGHT_AOV_INDIRECT = 1027836509
C4DAIP_SKYDOME_LIGHT_NAME = 1814347399

C4DAIP_VOLUME_FILENAME   = 1869200172
ARNOLD_SCENE_HOOK = 1032309
C4DTOA_MSG_TYPE = 1000
C4DTOA_MSG_GET_VERSION = 1040
C4DTOA_MSG_RESP1 = 2011
C4DTOA_MSG_RESP2 = 2012
C4DTOA_MSG_RESP3 = 2013

ID_PREFERENCES_NODE = 465001632 # Prefs ID
ID_MATERIAL_MANAGER: int = 12159

# 自定义aov名称
C4DTOA_AOVTYPES_UTIL: list[str] = [
    'beauty',
    'AA_inv_density',
    'ID',
    'N',
    'P',
    'Z',
    'Pref',
    'albedo',
    'background',
    'coat',
    'coat_albedo',
    'coat_direct',
    'coat_indirect',
    'cputime',
    'denoise_albedo',
    'denoise_albedo_noisy',
    'diffuse',
    'diffuse_albedo',
    'diffuse_direct',
    'diffuse_indirect',
    'direct',
    'emission',
    'indirect',
    'motionvector',
    'opacity',
    'raycount',
    'shadow_matte',
    'sheen',
    'sheen_albedo',
    'sheen_direct',
    'sheen_indirect',
    'specular',
    'specular_albedo',
    'specular_direct',
    'specular_indirect',
    'sss',
    'sss_albedo',
    'sss_direct',
    'sss_indirect',
    'transmission',
    'transmission_albedo',
    'transmission_direct',
    'transmission_indirect',
    'volume',
    'volume_Z',
    'volume_albedo',
    'volume_direct',
    'volume_indirect',
    'volume_opacity',
    'crypto_asset',
    'crypto_material',
    'crypto_object'       
    ]

C4DTOA_AOVTYPES_CRYPOTOMATTE: list[str] = ["cryptomatte","crypto_asset","crypto_material","crypto_object"]

C4DTOA_AOVTYPES_SHADOW: list[str] = ["shadow_matte","shadow","shadow_diff","shadow_mask"]

C4DTOA_AOVTYPES_HAIR: list[str] = ["standard_hair","id1","id2","id3","id4","id5","id6","id7","id8"]

C4DTOA_AOVTYPES_SURFACE: list[str] = ["standard_surface","id1","id2","id3","id4","id5","id6","id7","id8"]

C4DTOA_AOVTYPES_TOON: list[str] = ["highlight","rim_light"]

CDTOA_AOVTYPES: list[str] = C4DTOA_AOVTYPES_UTIL + C4DTOA_AOVTYPES_CRYPOTOMATTE + C4DTOA_AOVTYPES_SHADOW + C4DTOA_AOVTYPES_HAIR + C4DTOA_AOVTYPES_SURFACE + C4DTOA_AOVTYPES_TOON

C4DAIP_PHOTOMETRIC_LIGHT_FILENAME = 1413133543